import matplotlib.pyplot as plt
plt.ion()
import cartopy.crs as ccrs
import pandas as pd
from orbit_predictor.sources import NoradTLESource
from orbit_predictor.predictors import TLEPredictor
from matplotlib.image import imread
file = "HomemadeResource.txt"
C:\Users\timho\anaconda3\lib\site-packages\numpy\_distributor_init.py:32: UserWarning: loaded more than 1 DLL from .libs: C:\Users\timho\anaconda3\lib\site-packages\numpy\.libs\libopenblas.PYQHXLVVQ7VESDPUVUADXEVJOBGHJPAY.gfortran-win_amd64.dll C:\Users\timho\anaconda3\lib\site-packages\numpy\.libs\libopenblas.XWYDX2IKJW2NMTWSFYNGFUWKQU3LYTCZ.gfortran-win_amd64.dll stacklevel=1)
We are using TLE data. Specifically the second line is relevant for our orbital paramters. These look like this:
Since these orbital parameters are stored in a text file, we write some code to create a text file exactly in the shape required to read TLE data
#for handling the text files
def delete_last_line(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
# Remove the last line
lines = lines[:-1]
with open(file_path, 'w') as file:
file.writelines(lines)
#This is where we can define all of our orbital parameters
inclination = '70.0000'
ascending_node = '40.6214'
eccentricity = '0472482'
argument_of_perigee = '218.6408'
mean_motion = '14.45166658'
def write_parameters(inclination, ascending_node, eccentricity, argument_of_perigee, mean_motion):
delete_last_line(file)
with open(file, 'a') as the_file:
the_file.write('2 22490 ' + inclination+ ' ' + ascending_node +' '+ eccentricity + ' ' + argument_of_perigee +' 195.3393 '+ mean_motion + '638964\n')
write_parameters(inclination, ascending_node, eccentricity, argument_of_perigee, mean_motion)
#we define a simple sample satellite
source = NoradTLESource.from_file(file)
predictor = TLEPredictor("SCD 1", source)
def create_orbit(inclination, ascending_node, eccentricity, argument_of_perigee, mean_motion, image='SecondClassification.png'):
print(f'orbit plot for orbital parameters: \n inclination: {inclination} \n right ascension of the ascending node: {ascending_node} \n eccentricity: {eccentricity} \n argument of perigee: {argument_of_perigee} \n mean motion: {mean_motion}')
#write our specific parameters
write_parameters(inclination, ascending_node, eccentricity, argument_of_perigee, mean_motion)
#we define a sample satellite
source = NoradTLESource.from_file(file)
predictor = TLEPredictor("SCD 1", source)
#create the orbit
dates = pd.date_range(start="2017-12-11 00:00", periods=5000, freq="30S")
latlon = pd.DataFrame(index=dates, columns=["lat", "lon"])
for date in dates:
lat, lon, _ = predictor.get_position(date).position_llh
latlon.loc[date] = (lat, lon)
plt.figure(figsize=(15, 25))
ax =source_proj = plt.axes(projection=ccrs.PlateCarree())
#Load our specific classified landuse image
ax.imshow(imread(image), origin='upper', transform = ccrs.PlateCarree(),
extent=[-180, 180, -90, 90])
plt.plot(latlon["lon"], latlon["lat"], 'k',
transform=ccrs.Geodetic(),
)
plt.show()
Now that we have a function to create our orbits overlayed on our classified landuse map, we can create any orbit imagineable by tweaking the orbit parameters. Let's start by doing this for one orbit, and then let's do it for a lot:
create_orbit(inclination, ascending_node, eccentricity, argument_of_perigee, mean_motion)
orbit plot for orbital parameters: inclination: 70.0000 right ascension of the ascending node: 40.6214 eccentricity: 0472482 argument of perigee: 218.6408 mean motion: 14.45166658
Test orbit has been simulated. Now, let's make some more:
inclinations = ['20.0000','35.0000', '90.0000']
ascending_nodes = ['00.0000']
eccentricities = ['0372482']
argument_of_perigees = ['018.6408']
mean_motions = ['08.96676658']
for mean_motion in mean_motions:
for ascending_node in ascending_nodes:
for eccentricity in eccentricities:
for argument_of_perigee in argument_of_perigees:
for inclination in inclinations:
create_orbit(inclination, ascending_node, eccentricity, argument_of_perigee, mean_motion)
orbit plot for orbital parameters: inclination: 20.0000 right ascension of the ascending node: 00.0000 eccentricity: 0372482 argument of perigee: 018.6408 mean motion: 08.96676658
orbit plot for orbital parameters: inclination: 35.0000 right ascension of the ascending node: 00.0000 eccentricity: 0372482 argument of perigee: 018.6408 mean motion: 08.96676658
orbit plot for orbital parameters: inclination: 90.0000 right ascension of the ascending node: 00.0000 eccentricity: 0372482 argument of perigee: 018.6408 mean motion: 08.96676658
Now that we have chosen our final orbit according to the classified landuse map, we finally plot this chosen orbit above the normal map of Europa to create our final groundtrack:
create_orbit(inclination= '35.0000', ascending_node= '60.0000', eccentricity = '0372482', argument_of_perigee = '018.6408', mean_motion='08.96676658', image= 'EuropaMapHighRes.jpeg')
orbit plot for orbital parameters: inclination: 35.0000 right ascension of the ascending node: 60.0000 eccentricity: 0372482 argument of perigee: 018.6408 mean motion: 08.96676658